Skip to content

CEXT-6079: add unit tests for lib-app runtime actions#412

Open
vinayrao2000 wants to merge 3 commits intoadobe:mainfrom
vinayrao2000:CEXT-6079-add-tests-for-lib-app-rest-actions
Open

CEXT-6079: add unit tests for lib-app runtime actions#412
vinayrao2000 wants to merge 3 commits intoadobe:mainfrom
vinayrao2000:CEXT-6079-add-tests-for-lib-app-rest-actions

Conversation

@vinayrao2000
Copy link
Copy Markdown

@vinayrao2000 vinayrao2000 commented Apr 23, 2026

CEXT-6079: add unit tests for lib-app runtime actions

Description

Added a focused unit test suite for REST runtime actions in @adobe/aio-commerce-lib-app to cover handler behavior and regression scenarios.

Added test files

  • packages/aio-commerce-lib-app/test/fixtures/actions.ts
  • packages/aio-commerce-lib-app/test/unit/actions/app-config.test.ts
  • packages/aio-commerce-lib-app/test/unit/actions/config.test.ts
  • packages/aio-commerce-lib-app/test/unit/actions/scope-tree.test.ts
  • packages/aio-commerce-lib-app/test/unit/actions/installation.test.ts

Coverage scope

  • appConfigRuntimeAction
  • configRuntimeAction
  • scopeTreeRuntimeAction
  • installationRuntimeAction

The tests are unit-level with mocked dependencies and no external service calls.

Related Issue

CEXT-6079

Motivation and Context

lib-app REST runtime action behavior needed direct automated coverage for request/response paths and error handling.
This change improves confidence in action logic and catches regressions without requiring external integration setup.

How Has This Been Tested?

Executed from repo root:

  • pnpm test
  • pnpm typecheck

Both completed successfully in the local workspace.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have read the DEVELOPMENT document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 23, 2026

⚠️ No Changeset found

Latest commit: a7dfe53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added without-changeset The PR does not contain a Changeset file pkg: aio-commerce-lib-app Includes changes in `packages/aio-commerce-lib-app` labels Apr 23, 2026
Copy link
Copy Markdown
Collaborator

@iivvaannxx iivvaannxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only reviewed a couple of files for now. Probably the comments I added there also apply to the others.

Let's keep the tests focused to testing very specific things instead of having macro tests that assert multiple different things. Also make sure that you only "assert" those things that the test title describes, otherwise it can generate confusion if that test starts failing because of a change that seems unrelated 👍🏻

Comment on lines +87 to +92
expect(initializeMock).toHaveBeenCalledWith({ schema: configSchema });
expect(byScopeIdMock).toHaveBeenCalledWith("store-1");
expect(getConfigurationMock).toHaveBeenCalledWith(
{ scopeId: "store-1" },
{ encryptionKey: "encryption-key" },
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines seem to assert implementation details that this test should not care about. I'd remove them

}),
);

expect(initializeMock).toHaveBeenCalledWith({ schema: configSchema });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem on this initialize check. Don't think this test needs to care whether we call initialize or not.

Comment on lines +154 to +155
{ scopeId: "store-1" },
{ encryptionKey: undefined },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's assert only the parameters we want to actually check (in this case the first one). For others we can just expect.any(Object) or something like that. This way if those parameters are different in the future, these tests won't break.

Comment on lines +157 to +171
expect(result).toEqual({
type: "success",
statusCode: 200,
headers: {
"Cache-Control": "no-store",
Deprecation: "Wed, 15 Apr 2026 00:00:00 GMT",
},
body: {
scopeId: "store-1",
config: [
{ name: "apiKey", value: "*****", origin: "scope" },
{ name: "mode", value: "live", origin: "scope" },
],
},
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I would not assert the result in this test. I would only do it in a test that is intended to do that.

Comment on lines +93 to +106
expect(result).toEqual({
type: "success",
statusCode: 200,
body: {
schema: configSchema,
values: {
scopeId: "store-1",
config: [
{ name: "apiKey", value: "*****", origin: "scope" },
{ name: "mode", value: "live", origin: "scope" },
],
},
},
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably only assert the result in a specific test for the 200 result.

statusCode: 200,
headers: {
"Cache-Control": "no-store",
Deprecation: "Wed, 15 Apr 2026 00:00:00 GMT",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a specific test only for this header, to ensure future updates don't delete it.

});
});

test("forwards partial updates and null unsets with PATCH /", async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test it's a bit confusing to me. I would refactor it to two separate tests that assert the following:

  • PUT doesn't accept null values
  • PATCH does accept null values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: aio-commerce-lib-app Includes changes in `packages/aio-commerce-lib-app` without-changeset The PR does not contain a Changeset file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants